// import {getAdministrativeList} from "@/api/commons";
// import { Message } from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

const getTreeData = {
    namespaced: true,
    state: () => ({
        Village: [],
        Thecurrenttown: {},
        Thecurrentvillage: {}
    }),
    mutations: {
        getVillageData(state, arr) {
            state.Village = arr
        },
        setThecurrenttown(state, obj) {
            state.Thecurrenttown = obj
        },
        setThecurrentvillage(state, obj) {
            state.Thecurrentvillage = obj
        }
    },
    actions: {
        setAsyncVillageData(context) {
            let local = localStorage.getItem('getTreeData/setAsyncVillageData')
            context.commit('getVillageData', local)
        },
        setAsyncThecurrenttown(context, obj) {
            context.commit('setThecurrenttown', obj)
            return new Promise((resolve) => {
                resolve(obj)
            })
        },
        setThecurrentvillage(context, obj) {
            context.commit('setThecurrentvillage', obj)
            return new Promise((resolve) => {
                resolve(obj)
            })
        },
    },
    getters: {
        filtersVillage(state) {
            let local = localStorage.getItem('getTreeData/setAsyncVillageData')
            // console.log(JSON.parse(local)[0].children[0].children)
            return JSON.parse(local)[0].children[0].children || state.Village[0].children[0].children;
        }
    }
}

export default getTreeData

